# Google Apps API Wrapper copyright 2008-2009 Michael De Soto. This program is 
# distributed under the terms of the GNU General Public License, version 3.
#
# $Id: Token.pm 10 2008-12-10 14:16:09Z desoto@cpan.org $

package Google::Token;

use LWP::UserAgent;

use strict;
use warnings;

our $VERSION = '0.01';

sub get_token {
#    my $self = shift;
    my ($username, $password) = @_;
    
    my $ua = LWP::UserAgent->new;
    
    # $url should be in constant variable or config file;
    my $url = 'https://www.google.com/accounts/ClientLogin';
    my $response = $ua->post( $url,
        [ 'accountType' => 'HOSTED',
          'Email' => $username,
          'Passwd' => $password,
          'service' => 'apps'
        ]
    );
    
    return $response->content;
}

1;

__END__
